import asyncio


async def async_generator_example():
    for i in range(3):
        await asyncio.sleep(0.1)  # 模拟异步操作
        yield i


async def main():
    async_gen = async_generator_example()  # 创建异步生成器对象
    # 使用__anext__()方法调用，返回一个可等待对象
    value1 = await async_gen.__anext__()
    print(value1)

    value2 = await async_gen.__anext__()
    print(value2)

    value3 = await async_gen.__anext__()
    print(value3)


if __name__ == "__main__":
    asyncio.run(main())